package nix.anim.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import nix.anim.common.pojo.NixResult;
import nix.anim.mapper.LogLoginMapper;
import nix.anim.pojo.LogLogin;
import nix.anim.pojo.LogLoginExample;

/**
 * 用户管理Service
 */
@Service
public class LogLoginServiceImpl implements nix.anim.service.LogLoginService {

	@Autowired
	private LogLoginMapper logLoginMapper;
	
	@Value("${MAX_LIST_COUNT}")
	private Integer MAX_LIST_COUNT;
	
	@Override
	public NixResult getLogLoginList(Integer page, Integer rows) {
		if (page == null || page <= 0) {
			page = 1;
		}
		if (rows == null || rows <= 0 || rows > MAX_LIST_COUNT) {
			rows = MAX_LIST_COUNT;
		}
		// 分页信息
		PageHelper.startPage(page, rows);
		// 执行查询
		LogLoginExample example = new LogLoginExample();
		example.setOrderByClause("logined desc");
		List<LogLogin> list = logLoginMapper.selectByExample(example);
		// 取查询结果
		PageInfo<LogLogin> pageInfo = new PageInfo<>(list);
		// 返回
		return NixResult.ok(pageInfo);
	}
	
}
